package cn.hzking.gjmall.adpters.address;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.hzking.gjmall.R;
import cn.hzking.gjmall.activitys.my.AddAdressActivity;
import cn.hzking.gjmall.bean.address.AddressSimpleBean;

import static android.app.Activity.RESULT_OK;

/**
 * Created by Administrator on 2018/3/2.
 */

public class SelectAddressAdapter extends BaseQuickAdapter<AddressSimpleBean.DataBean.DeliveryAddressesListBean,BaseViewHolder> {
    public SelectAddressAdapter(int layoutResId, @Nullable List<AddressSimpleBean.DataBean.DeliveryAddressesListBean> data) {
        super(layoutResId, data);
    }

    private AddressInterface addressInterface;

    public AddressInterface getAddressInterface() {
        return addressInterface;
    }

    public void setAddressInterface(AddressInterface addressInterface) {
        this.addressInterface = addressInterface;
    }

    @Override
    protected void convert(BaseViewHolder helper, final AddressSimpleBean.DataBean.DeliveryAddressesListBean item) {
        TextView nameTv=helper.getView(R.id.tv_name);
        TextView telTv=helper.getView(R.id.tv_tel);
        TextView addressTv=helper.getView(R.id.tv_address);
        nameTv.setText(item.getReceiverName());
        telTv.setText(item.getReceiverTel());
        addressTv.setText(item.getLongAddress());
        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               addressInterface.select(item.getId());
            }
        });
    }

    public interface AddressInterface{
        public void select(int addressId);
    }
}
